import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton, OpenTwoRouter } from '../Common/options'

export const ResearchDevelopments = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    url: 'getResearchDevelopmentExcel',
                    pos: 'posResearchDevelopmentExcel',
                }}
            />,
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'ResearchDevelopments' },
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, title: '项目名称' },
            {
                dataIndex: 'eventDate',
                title: '日期',
                valueType: 'Date',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            { ...commonTableList.tableName, title: '课题名称' },
            {
                dataIndex: 'researcherSalary',
                title: '研究人员工资',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'rawMaterialCost',
                title: '原材料费',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'equipmentDepreciation',
                title: '设备调整费及折旧',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },
            {
                dataIndex: 'otherExpenses',
                title: '其他费',
                valueType: 'input',
                ellipsis: true,
                width: 200,
                hideInSearch: true,
            },

            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoTwo"
                            title="附件管理"
                            twoTitle="科研费用附件信息"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'AttachmentDetails',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
